{layout name="layout/food" /}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">门店列表</div>
                </div>
                <div class="widget-body am-fr">
					<!-- 工具栏 -->
					{if $user['applet']['shop_mode']['value']==20}
                    <div class="page_toolbar am-margin-bottom-xs am-cf">
                        <div class="am-u-sm-12 am-u-md-3">
							<div class="am-form-group">
								<div class="am-btn-group am-btn-group-sm">
									<a class="am-btn am-btn-primary am-radius" href="{:url('food.shop/add')}">
										<span class="am-icon-plus"></span> 新增
									</a>
								</div>
							</div>
						</div>
                    </div>
					{/if}
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-hover tpl-table-black">
                            <thead>
                            <tr>
                                <th>门店ID</th>
                                <th>门店LOGO</th>
                                <th>门店名称</th>
                                <th>营业时间</th>
                                <th>联系人</th>
                                <th>联系电话</th>
								<th>二维码</th>
								<th>门店状态</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if $list}
                                {foreach $list as $item}
                                <tr>
                                    <td class="am-text-middle">{$item['shop_id']}</td>
                                    <td class="am-text-middle">
                                        <img src="{$item['logo']}" width="50" height="50" alt="门店图片">
                                    </td>
                                    <td class="am-text-middle">
                                        <p class="item-title">{$item['shop_name']}</p>
                                    </td>
                                    <td class="am-text-middle">{$item['shop_hours']}</td>
                                    <td class="am-text-middle">{$item['linkman']}</td>
                                    <td class="am-text-middle">{$item['phone']}</td>
									<td class="am-text-middle">
                                        <a href="{:url('food.shop/qrcode',['id' => $item['shop_id']])}" title="点击查看大图" target="_blank">
                                            <i class="iconfont iconerweima" style="font-size:20px;"></i>
                                        </a>
									</td>
                                    <td class="am-text-middle">
                                            <span class="j-state am-badge x-cur-p {$item['status']['value'] ? ' am-badge-success' : ' am-badge-warning'}" 
                                                 data-ids="{$item['shop_id']}"
                                                 data-status="{$item['status']['status']}">
                                            {$item['status']['text']}
                                            </span>
                                    </td>
                                    <td class="am-text-middle">{$item['create_time']}</td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="{:url('food.shop/edit',['id' => $item['shop_id']])}">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="javascript:;" class="item-del tpl-table-black-operation-del"
                                               data-id="{$item['shop_id']}">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                            {else /}
                                <tr>
                                    <td colspan="10" class="am-text-center">暂无记录</td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr">{:$list->render()} </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：{:$list->total()}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
		
		// 切换状态
        $('.j-state').click(function () {
            var data = $(this).data();
			var msg = '确定要'+(parseInt(data.status) === 1 ? '暂停营业' : '开启营业')+'吗？';
			$('.j-state').del('id', "{:url('food.shop/status')}",msg);
        });

        $('.item-del').del('id', "{:url('food.shop/delete')}");// 删除元素

    });
</script>

